package com.zjeav.lingjiao.ui.register;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.dalimao.corelibrary.VerificationCodeInput;

import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.baseBean.BaseActivity;
import com.zjeav.lingjiao.base.view.PhoneCode;

public class RegisterActivity extends BaseActivity {
    PhoneCode editsms;
    Button next_bn;
    String code;
    String phone;
    String val_code;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceStat) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.input_code_layout);
        code = getIntent().getStringExtra("code");
        phone = getIntent().getStringExtra("phone");
        editsms = findViewById(R.id.editsms);
        next_bn = findViewById(R.id.next_bn);

        editsms.setOnInputListener(new PhoneCode.OnInputListener() {
            @Override
            public void onSucess(String code) {
                val_code = code;
            }

            @Override
            public void onInput() {
                //TODO:
            }
        });

        next_bn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (code.equals(val_code)) {

                    Intent intent = new Intent(RegisterActivity.this, RegisterDetialActivity.class);
                    intent.putExtra("phone", phone);
                    startActivity(intent);
                } else {
                    Toast.makeText(RegisterActivity.this, "验证码不正确", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}
